<template>
  <view class="productCode">
    <view class="productCode-search">
      <view class="productCode-search-component">
        <uni-section type="line">
        	<uni-search-bar @confirm="search" v-model="searchValue" @blur="blur" 
          @focus="focus" @input="input"
        		@cancel="cancel" @clear="clear" cancelButton="none" 
            placeholder="请输入至少四位产品编码">
            
 <!--           <template v-slot:searchIcon>
            		<uni-icons  color="#3d5690" size="20" type="scan" @click="uploadImage"/>
            </template> -->
            
            <template v-slot:clearIcon>
            		<uni-icons  color="#3d5690" size="18" type="closeempty" />
            </template>
              
        	</uni-search-bar>
          <button class="productCode-search-button" @click="productCodeSearch">查询</button>
        </uni-section>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    options: {
    	styleIsolation: 'shared', // 解除样式隔离
    },
    data(){
      return {
        searchValue:'',
      }
    },
    props:{},
    methods:{
      search(){},
      blur(){},
      focus(){},
      input(){},
      clear(){},
      // uploadImage(){
      //   let _this = this
      //   uni.chooseImage({
      //   	count: 6, //默认9
      //   	sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
      //   	sourceType: ['album'], //从相册选择
      //   	success: function (res) {
      //   		console.log(JSON.stringify(res.tempFilePaths));
      //   	}
      //   });
      // },
      productCodeSearch(){
        let value = this.searchValue.trim()
        if(value == ''){
          this.$modal.alert("请输入产品编码")
          return 
        }
        let reg = /\w/
        if(!reg.test(value)){
          this.$modal.alert("产品编码格式错误")
          return 
        }
        let countReg = /\w{4,}/
        if(!countReg.test(value)){
          this.$modal.alert("至少四位产品编码")
          return 
        }
        this.searchValue = ''
        this.$tab.navigateTo(`/pages/eCatalog/index?skipNumber=${value}&from=3`)
      }
    },
    created(){},
  }
</script>

<style>
  @import url('../../static/style/productCode/productCode.css');
</style>